//
//  ShareViewController.m
//  happyHealthyWalk
//
//  Created by newhuidong on 16/2/22.
//  Copyright © 2016年 HuiDong. All rights reserved.
//

#import "ShareViewController.h"
#import "Header.h"
#import "HeartViewController.h"
#import "HeartshareViewController.h"
#import "TogetherViewController.h"

@interface ShareViewController ()<FJSlidingControllerDataSource,FJSlidingControllerDelegate>

@property(nonatomic,strong)NSArray * titles;
@property(nonatomic,strong)NSArray *controllers;


@end

@implementation ShareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.datasouce=self;
    self.delegate=self;
    
    
 //   HeartViewController * vc1=(HeartViewController *)self.parentViewController;
    
    
    HeartViewController * vc1=[[HeartViewController alloc]init];
    vc1.parentController=self;
    
    
//    HeartshareViewController* vc2=(HeartshareViewController*)self.parentViewController;
    
    HeartshareViewController * vc2=[[HeartshareViewController alloc]init];
    vc2.parentController=self;
    
    TogetherViewController * vc3=[[TogetherViewController alloc]init];
    vc3.parentController=self;

//    TogetherViewController * vc3=(TogetherViewController*)self.parentViewController;
    
    
    self.titles=@[@"从心出发",@"真情分享",@"你我相伴",];
    
    self.controllers=@[vc1,vc2,vc3];
    [self addChildViewController:vc1];
    [self addChildViewController:vc2];
    [self addChildViewController:vc3];

    self.title=self.titles[0];
    
    [self reloadData];
    
    
    
    
    self.navigationController.navigationBar.translucent=NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage=[UIImage new];
    
    self.navigationController.navigationBar.barTintColor=GreenColor;
    self.title=@"健康知识";
    
    self.navigationController.navigationBar.tintColor=[UIColor whiteColor];
    
    
}

-(NSInteger)numberOfPageInFJSlidingController:(FJSlidingController *)fjSlidingController{
    
    return self.titles.count;
    
}
-(UIViewController*)fjSlidingController:(FJSlidingController *)fjSlidingController controllerAtIndex:(NSInteger)index{
    
    return self.controllers[index];
    
}
-(NSString*)fjSlidingController:(FJSlidingController *)fjSlidingController titleAtIndex:(NSInteger)index{
    
    return self.titles[index];
    
}

#pragma delegate

-(void)fjSlidingController:(FJSlidingController *)fjSlidingController selectedIndex:(NSInteger)index{
    
    self.title=[self.titles objectAtIndex:index];
    
}
-(void)fjSlidingController:(FJSlidingController *)fjSlidingController selectedController:(UIViewController *)controller{
    // presentController
}
-(void)fjSlidingController:(FJSlidingController *)fjSlidingController selectedTitle:(NSString *)title{
    // presentTitle
}
-(void)dealloc{
    NSLog(@"!dealloc!");
}

@end
